﻿#查找路径下面所有源文件
aux_source_directory(. SRC_LIST)

#引用头文件目录

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/include)



#引用库目录
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")  
    LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/lib)

ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Windows") 
 
     IF(CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "None")  
    		 LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/lib/Debug)  
     ELSEIF(CMAKE_BUILD_TYPE MATCHES "Release")  
                LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/lib/Release)
     ELSE()  
     		LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/lib)
     ENDIF()

ELSE()  
    LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/3rdlib/lib)

ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")

#引用库名
set(MY_LIBS testdll testlib)
set(LINK_LIST "")
foreach(x ${MY_LIBS})
    list (APPEND LINK_LIST debug ${x}_gd optimized ${x})
endforeach()


#生成exe文件
ADD_EXECUTABLE(testlink ${SRC_LIST})

#添加库
target_link_libraries(testlink ${LINK_LIST})

#设置预编译
SET_TARGET_PROPERTIES(testlink PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "stdafx.h")
cotire(testlink)

#设置目录
set_target_properties(testlink PROPERTIES FOLDER "TestCmake")

#复制头文件到inchhvi
#install(FILES test.h DESTINATION ${PROJECT_SOURCE_DIR}/3rdlib/include)


